"""author: mibo
   data: 2020/10/26
   project: pythonProject
"""
import re

# nu = lambda x, y: x if x > y else y


# print(nu(5, 4))


def fab(n):
    if n < 1:
        print("输入错误")
    elif n == 1 or n == 2:
        return 1
    else:
        return fab(n - 2) + fab(n - 1)


bmi = lambda s, k: print(k / (s ** 2))


def length(str):
    if len(str) >= 8:
        return 1
    else:
        return 0


def complex(str):
    p = r'^(?![A-Za-z]+$)(?![A-Z\\d]+$)(?![A-Z\\W]+$)(?![a-z\\d]+$)(?![a-z\\W]+$)'
    res = re.search(p, str)
    if res:
        return 1
    else:
        return 0


def judge(str):
    ju = 0
    for i in range(len(str)):
        if str.count(str[i:i + 3]) >= 2:
            ju += 1
    if ju > 0:
        return 0
    else:
        return 1




def passwd_de(str):
    grade = 2
    if length(str):
        grade += 1
        if complex(str):
            grade += 1
        else:
            print("密码不包括大、小写字母.数字.其它符号,以上四种至少三种")
        if judge(str):
            grade += 1
        else:
            print("密码不能有长度超过或等于3的子串重复")
    else:
        print("密码长度没有达到8位")
    print(f"你的密码评分为{grade}")
    if grade == 5:
        print("密码达标")
    return grade


passwd = input("请输入密码： ")
passwd_de(passwd)
